<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="m" uri="/cutm_tags"%>
<html>
<head>
<title>设备新增</title>
<link rel="stylesheet" href="<s:url value="/common/css/nyroModal.css"/>" type="text/css" />
<script type="text/javascript"	src="<s:url value="/common/scripts/jquery.nyroModal-1.5.5.js"/>"></script>
	
<script type="text/javascript">

$(document).ready(function(){
	$("#editDevicesForm").vaildAjax(function(data){
		var str = data.split(";");
		if(str[0]=='yes'){
			BaseJs.setReadonly();
			$("#st").hide("slow");
		}
		BaseJs.alert(str[1]);
		});
	$("#selectSupply").click(function(){
		var item =$('input[name="supInfo"]:checked');
		//var item = $('input[name="supInfo"][checked = true]');
		if(item.length >0){
			fillSupplyInfo(item.val());
		}else{
			BaseJs.alert("请先选择设备供应方信息！！");
			return false;
		}
	});
	$("#pop").click(function(){
		$("#topop").trigger("click");
	});
});
function commit() {
	$('#editDevicesForm').submit();
}
function fillSupplyInfo(info){
	$("#hiddsup").val("").val(getSupplyId(info));
	$("#viewsupInof").empty().val(info);	
}
function getSupplyId(info){
	return info.substring(info.indexOf("(")+1,info.indexOf(")"));
}
</script>
</head>
<body>
<h2 class="title">设备信息添加</h2>
<s:form id="editDevicesForm" action="devices/EditDevices">
	<s:hidden name="devices.id"/>
	<table class="form">
		<tr>
			<th width="10%"><span class="hint">*</span>设备类别：</th>
			<td width="20%"><m:select enumType="devices.type" name="devices.devicetype" /></td>
			<th width="10%"><span class="hint">*</span>设备名称：</th>
			<td width="20%"><s:textfield name="devices.deviceName" cssClass="rule[required]" /></td>
			<th width="10%"><span class="hint">*</span>设备编号：</th>
			<td width="30%"><s:textfield name="devices.deviceNo" cssClass="rule[required]" /></td>
		</tr>
		<tr>
			<th><span class="hint">*</span>设备购买日期：</th>
			<td colspan="1"><m:date name="devices.buyDate" cssClass="rule[required time]" time="true" /> </td>
			<th>设备购买方: </th>
			<td  colspan="3"><s:select list="devicesSupplys" name="devices.deviceSupply.id" label="设备购买方" listKey="key"
				listValue="value" headerKey="0" headerValue="--请选择--" value="devices.deviceSupply.id"></s:select>
			</td>
		</tr>
		<tr>
			<th><span class="hint">*</span>设备当前状态：</th>
			<td colspan="1"><m:select enumType="devicestatus.type" name="devices.deviceState" /></td>
			<th><span class="hint">*</span>有效状态：</th>
			<td colspan="3"><s:radio list='#{ false:"无效", true:"有效"}' name="devices.enable" value="true"/></td>
		</tr>
		<tr>
			<th width="20%">备注：</th>
			<td colspan="5"><s:textarea name="devices.deviceInfo"/></td>
		</tr>
	</table>
	
	
	<div class="btnGroup"><input type="button" value="提交" onclick="commit()" id="st"/> <input
		type="button" value="返回列表" onclick="BaseJs.toAction('devices/ListDevices');" /></div>
</s:form>
</body>
</html>